package com.brilliance.project.webapp.action.sample;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.brilliance.project.service.sample.IBrt_sService;
import com.brilliance.project.service.sample.ISampleService;
import com.brilliance.project.webapp.action.BaseAction;
import com.brilliance.project.webapp.form.sample.SampleForm;

@Component("sampleAction")
public class SampleAction extends BaseAction {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * 查询的字段
	 */
	private SampleForm sampleForm;

	private List<SampleForm> queryList;

	/**
	 * struts2 textfield标签
	 */
	private String textfield = null;

	@Autowired
	private ISampleService sampleSeviceImpl;
	@Autowired
	private IBrt_sService brt_sServiceImpl;

	public String execute() {
		
		return SUCCESS;
	}
	  public void validate() {
		  
	  }
	
	public String query() {
		queryList = sampleSeviceImpl.query(sampleForm);
//		List <String>list = new ArrayList<String>();
//		list.add("adfad");
//		getFieldErrors().put("errId",list );
		//addFieldError("errId", "aaaa");
		//addActionError("aaaaaaaaaaaaaaaaaaaaaa");
		Map <String,String> map = new HashMap<String,String>();
		map.put("aa", "bbb");
		application.put("auth", map);
		
		return SUCCESS;
	}

	public String test() throws Exception {
		System.out.println(textfield);
		textfield = textfield + "submit";
		textfield = sampleSeviceImpl.test(textfield);
		return SUCCESS;
	}

	// ---------getter and setter---//
	public String getTextfield() {
		return textfield;
	}

	public void setTextfield(String textfield) {
		this.textfield = textfield;
	}

	public ISampleService getSampleSeviceImpl() {
		return sampleSeviceImpl;
	}

	public void setSampleSeviceImpl(ISampleService sampleSeviceImpl) {
		this.sampleSeviceImpl = sampleSeviceImpl;
	}

	public SampleForm getSampleForm() {
		return sampleForm;
	}

	public void setSampleForm(SampleForm sampleForm) {
		this.sampleForm = sampleForm;
	}

	public void setQueryList(List<SampleForm> queryList) {
		this.queryList = queryList;
	}

	public List<SampleForm> getQueryList() {
		return queryList;
	}
	public IBrt_sService getBrt_sServiceImpl() {
		return brt_sServiceImpl;
	}
	public void setBrt_sServiceImpl(IBrt_sService brt_sServiceImpl) {
		this.brt_sServiceImpl = brt_sServiceImpl;
	}

	

}
